package com.demo.web.modules.mod;

import com.demo.common.constant.api.base.IDEntity;
import com.demo.common.result.ResponseInfo;
import com.demo.common.result.ResultVo;
import com.demo.service.mod.ModPageService;
import com.github.pagehelper.PageInfo;
import com.demo.dao.mod.entity.ModPageItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/mod/mod_page")
public class ModPageController {
    @Autowired
    private ModPageService myService;


    @RequestMapping("/test")
    public String test(){
        return "hello, you are in ModPageItem test!";
    }

    @RequestMapping(value = "/page", method = RequestMethod.POST)
    public ResultVo findModPage (@RequestBody Map<String, String> map) {
        //取出分页信息
        Integer pageNum = Integer.parseInt(map.get("pageNum").toString());
        Integer pageSize= Integer.parseInt(map.get("pageSize").toString());

        return ResponseInfo.<PageInfo<ModPageItem>>success(myService.findModPage(map, pageNum, pageSize));
    }

    //删除
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public ResultVo removeModPage(@RequestBody IDEntity<Long> ids){
        return ResponseInfo.<Object>success(myService.removeModPage(ids.getId()));
    }
}
